package com.zb.file.controller;
import com.zb.file.service.FileService;
import com.zb.result.Result;
import com.zb.utils.TokenUtil;
import com.zb.yaml.FilePath;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author WEN
 * @Date 2023/8/11 0011
 **/
@Api(tags = "视频文件上传接口")
@RestController
@RequestMapping("/file/video")
public class VideoFileController {
    @Resource
    private FileService fileService;

    @ApiOperation("知识中心视频上传")
    @PostMapping("/knowledgeUpload")
    public Result knowledgeUpload(HttpServletRequest request, @ApiParam(value = "文件，以二进制方式上传（form-data），支持多个上传") List<MultipartFile> files) {
        String custAccVideoCode = TokenUtil.getCustAccVideoCode(request);
        List<String> paths = fileService.knowledgeUpload(FilePath.videoUploadPath(), FilePath.domain() + FilePath.videoVisitPath(), custAccVideoCode, files);
        return Result.success("视频上传成功！").data("rows", paths);
    }


    @ApiOperation("工单视频上传")
    @PostMapping("/orderVideoUpload")
    public Result orderVideoUpload(HttpServletRequest request, @ApiParam(value = "文件，以二进制方式上传（form-data），支持多个上传") List<MultipartFile> files) {
        String custAccVideoCode = TokenUtil.getCustAccVideoCode(request);
        List<String> paths = fileService.orderVideoUpload(FilePath.videoUploadPath(), FilePath.domain() + FilePath.videoVisitPath(), custAccVideoCode, files);
        return Result.success("工单视频上传成功！").data("rows", paths);
    }



}
